﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text.RegularExpressions;

namespace SalaryChannel
{
    public class DataHelper
    {

        public static string DateRegexString = @"^(?:((((0[0-9])(([02468][48])|([13579][26]))-0?2-29))|(((0[0-9])(([2468][048])|([13579][26]))-0?2-29))|(((0[1-9])(([02468][048])|([13579][26]))-0?2-29))|((([1-9][0-9])(([02468][048])|([13579][26]))-0?2-29))|((0[0-9][0-9][1-9])|(0[0-9][1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0?[1-9])|(1[0-2]))-((0?[1-9])|(1[0-9])|(2[0-8])))|((((0?[13578])|(1[02]))-31)|(((0?[1,3-9])|(1[0-2]))-(29|30))))))$";
        public static string PostCodeRegexString = @"^(?:\d{6})$";
        public static string EmailRegexString = @"^(?:.+@\w+(\.\w+)+)$";
        public static string ChineseRegexString = @"^(?:[\u4E00-\u9FFF]+)$";
        public static string PhoneNumRegexString = @"^1((3[4-9])|(47)|(5[0128])|(8[2378]))\d{8}$";
        /// <summary>
        /// 提取[1]test中的1
        /// </summary>
        /// <param name="IDAndName"></param>
        /// <returns>输入字符串不匹配样式，返回-1；否则，返回ID</returns>
        public static int GetIDOFIDAndName(string IDAndName)
        {
            Regex r = new Regex(@"^\[(?<ID>\d+)\].*$");
            if (!r.IsMatch(IDAndName))
            {
                return -1;
            }
            return int.Parse(r.Match(IDAndName).Result("${ID}"));
        }

    }
}
